//
//  PlSUpdateUI.h
//  PlugSuit
//
//  Created by ∞ on 20/12/07.
//  Copyright 2007 Emanuele Vulcano (infinite-labs.net). All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "PlSPlugIn.h"
#import "PlSUpdateInfo.h"

enum {
	kPlSUpdateResultAccept,
	kPlSUpdateResultCancel,
	kPlSUpdateResultNotAvailable,
	kPlSUpdateResultNotNeeded,
	kPlSUpdateResultNotSupported,
};
typedef NSInteger PlSUpdateResult;

static inline NSString* PlSStringFromUpdateResult(PlSUpdateResult r) {
	switch (r) {
		case kPlSUpdateResultAccept:
			return @"Accepted";
		case kPlSUpdateResultCancel:
			return @"Canceled";
		case kPlSUpdateResultNotAvailable:
			return @"Not available";
		case kPlSUpdateResultNotNeeded:
			return @"Not needed";
		case kPlSUpdateResultNotSupported:
			return @"Not supported";
		default:
			return @"Unknown";
	}
}

@interface PlSUpdateUI : NSObject {
	id _delegate;
	SEL _didEnd;
	void* _context;
	PlSUpdateInfo* _info;
	
	PlSUpdateResult _lastResult;
	
	NSBundle* _appBundle;
	NSLocale* _locale;
	BOOL _displayNoticeIfNoUpdate;
	BOOL _activateBeforeShowingAlerts;
}

@property(retain) NSBundle* applicationBundle;
@property(retain) NSLocale* locale;
@property BOOL displayNoticeIfNoUpdate;
@property BOOL activateBeforeShowingAlerts;

- (void) setApplicationBundleAndLocale:(NSBundle*) bundle;

// didEnd like: -updateUI:(PlSUpdateUI*) ui didEndUpdateWithResult:(PlSUpdateResult) result context:(void*) context;
- (void) beginCheckForAppUpdateModalForWindow:(NSWindow*) window delegate:(id) delegate didEndSelector:(SEL) didEnd context:(void*) context;
- (void) beginCheckForUpdateForPlugIn:(PlSPlugIn*) pin modalForWindow:(NSWindow*) window delegate:(id) delegate didEndSelector:(SEL) didEnd context:(void*) context;

@end
